package by.grsu.aksiutsik.Initialiser;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import by.grsu.aksiutsik.dao.AbiturietDao;
import by.grsu.aksiutsik.dao.AdministratorDao;
import by.grsu.aksiutsik.dao.FakultetDao;
import by.grsu.aksiutsik.entity.Abituriet;
import by.grsu.aksiutsik.entity.Administrator;
import by.grsu.aksiutsik.entity.Fakultet;

import com.epam.grsulab.webapi.dao.base.Dao;
import com.epam.grsulab.webapi.entity.base.BaseEntity;
import com.epam.grsulab.webapi.tools.DataInitialiser;

@Component

public class DataInitialiserImpl implements DataInitialiser {
	private static final Logger logger = LoggerFactory.getLogger(DataInitialiserImpl.class);
 @Autowired
private AbiturietDao abiturietDao;
@Autowired
private FakultetDao fakultetDao;
@Autowired
private AdministratorDao administratorDao;
@Override
public void initData() {
	 Fakultet fakult2 = new Fakultet();
	fakult2.setFname("mathfakultet");
	fakult2.setNabor(250);
	fakult2.setPredmet1("math");
	fakult2.setPredmet2("language");
	fakult2.setPredmet3("physics");
	fakult2.setSredball(7);
   fakult2=fakultetDao.save(fakult2);
	 Administrator admin = new Administrator();
	admin.setN(3);
	admin=administratorDao.save(admin);
	
	 Abituriet abit=new Abituriet();
	abit.setAttball(5);
	abit.setBall1(4);
	abit.setBall2(6);
	abit.setBall3(9);
	abit.setName("Sergei");
	abit.setFamilia("Ivanov");
	abit.setPredmet1("math");
	abit.setPredmet2("language");
	abit.setPredmet3("phisics");
	abit.setAdmin(admin);
	abit.setFakult(fakult2);
	abit=abiturietDao.save(abit);

}
@Override
public List<Dao<? extends BaseEntity>> getAllDAOs() {
	// TODO Auto-generated method stub
	List<Dao<? extends BaseEntity>> list = new ArrayList<Dao<? extends BaseEntity>>();
list.add(fakultetDao);
	list.add(administratorDao);
	list.add(abiturietDao);
	return list;
	
}
}
